<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="./layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
          
<blockquote class="layui-elem-quote layui-text">
  鉴于小伙伴的普遍反馈，先温馨提醒两个常见“问题”：1. <a href="/doc/base/faq.html#form" target="_blank">为什么select/checkbox/radio没显示？</a> 2. <a href="/doc/modules/form.html#render" target="_blank">动态添加的表单元素如何更新？</a>
</blockquote>
              
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>表单集合演示</legend>
</fieldset>
 
<form class="layui-form" action="">
  <div class="layui-form-item">
    <label class="layui-form-label">订单总价</label>
    <div class="layui-input-block">
      <input name="price" class="layui-input" type="text" placeholder="请输入" autocomplete="off" lay-verify="required|price" lay-reqtext="订单总价是必填项，岂能为空？">
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">下单时间</label>
    <div class="layui-input-block">
      <input name="datatime" class="layui-input" type="text" placeholder="请输入" autocomplete="off" lay-verify="required|datatime" lay-reqtext="下单时间是必填项，岂能为空？">
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
      <input name="status" class="layui-input" type="text" placeholder="请输入" autocomplete="off" lay-verify="required|status" lay-reqtext="状态是必填项，岂能为空？">
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">会员名称</label>
    <div class="layui-input-block">
      <input name="name" class="layui-input" type="text" placeholder="请输入" autocomplete="off" lay-verify="required|name" lay-reqtext="会员名称是必填项，岂能为空？">
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">手机号</label>
    <div class="layui-input-block">
      <input name="tel" class="layui-input" type="text" placeholder="请输入" autocomplete="off" lay-verify="required|tel" lay-reqtext="手机号是必填项，岂能为空？">
    </div>
  </div>
  <div class="layui-form-item">
    <button class="layui-btn" lay-filter="demo2" lay-submit="">添加</button>
  </div>
</form>
          
<script src="./layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,$ = layui.$;
  //监听提交
  form.on('submit(demo2)', function(data){
    $.ajax({
      url:'http://127.0.0.1/1028/php/public/index.php/Index/Add/add',
      data:data.field,
      datatype:'json',
      type:'post',
      success:function(res)
      {
        layer.res(res.msg);
        if(res.code==0)
        {
          location.href='fen.html'
        }
      }
    })
    // layer.alert(JSON.stringify(data.field), {
    //   title: '最终的提交信息'
    // })
    return false;
  });
});
</script>

</body>
</html>